<?php
	//include_once('Models/LopHocPhan.php');
	include_once('Configs/database.php');
	include_once('Models/NhatKi.php');
	include_once('Models/LopHocPhan.php');
	include_once('Models/BoMon.php');
	include_once('Models/Khoa.php');
	$nhatki = new NhatKi();;
	$lophp = new LopHocPhan();
	
	$db = new database();
	//$namhoc = $_GET['namhoc'];
	//$hocki = $_GET['hocki'];
	//$maso = $_GET['maso'];
	//$mabm = $_GET['mabm'];
	$query = "select distinct a.maso,concat(holot, ' ', ten) as hoten, tenhp,kihieu,sotc,a.malophp,siso,a.mahp,manhom,sotietlithuyet,sotietthuchanh ";
	$query .= "from LopHocPhan a, HocPhan b, CanBo c,CanBoGiangDay d ";
	$query .= "where hocki=".$hocki." and namhoc='".$namhoc."' and mabm='".$mabm."' ";
	$query .= "and a.mahp = b.mahp and a.maso = c.maso and c.maso = d.maso order by hoten ";
	$db->setQuery($query);
	
	$result = $db->fetchAll();
	
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="Libraries/css/style.css" rel="stylesheet" type="text/css" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style4 {font-family: tahoma}
.khung {
	border: medium solid #000000;
}
-->
</style>
</head>

<body>

<br />
<table align="center" width="100%"  cellspacing="0" cellpadding="0" >
  <tr>
    <td class="main_1"><img border="0" src="Libraries/images/tbl_left.gif" width="10" height="25" /></td>
    <td align="center" class="main_1">Thống Kê Tổng Hợp- Học kì:
      <?php echo $hocki?>-Năm học:<?php echo $namhoc?></td>
    <td class="main_1"><p align="right"><img border="0" src="Libraries/images/tbl_right.gif" width="10" height="25" /></p></td>
  </tr>
  
  <tr>
  	<td class="border_1" colspan="3" valign="top">
		<table width="100%" align="center"  cellpadding="0" cellspacing="0">
			<tr>
				<td colspan="17" align="center" class="main_3" >Bộ môn: <?php echo $tenbm?> - Khoa: <?php echo $tenkhoa?></td>
			</tr>
		  <tr>
			<td colspan="3" rowspan="3" align="center" valign="middle" class="main_3">TT Mã số Họ và tên GV </td>
			<td width="50" rowspan="3" align="center" valign="middle" class="main_3">MSHP</td>
			<td width="29" rowspan="3" align="center" valign="middle" class="main_3">Số TC </td>
			<td width="42" rowspan="3" align="center" valign="middle" class="main_3">MS lớp HP </td>
		
			<td width="35" rowspan="3" align="center" valign="middle" class="main_3">SS.sv</td>
			<td colspan="9" align="center" valign="middle" class="main_3">Khối lượng tiết giảng(G) </td>
			<td width="126" rowspan="2" align="center" valign="middle" class="main_3">Ghi Chú </td>
		  </tr>
		  <tr>
			<td colspan="3" align="center" valign="middle" class="main_3">Kế họach(G1) </td>
		
			<td colspan="3" align="center" valign="middle" class="main_3">Thực hiện(G2) </td>
			<td colspan="3" align="center" valign="middle" class="main_3">Khác biệt(G2-G1) </td>
		  </tr>
		  <tr>
			<td align="center" valign="middle" class="main_3">LT</td>
			<td align="center" valign="middle" class="main_3">TH</td>
			<td width="40" align="center" valign="middle" class="main_3">Tổng</td>
		
			<td width="30" align="center" valign="middle" class="main_3">LT </td>
			<td width="28" align="center" valign="middle" class="main_3">TH</td>
			<td width="31" align="center" valign="middle" class="main_3">Tổng</td>
			<td width="25" align="center" valign="middle" class="main_3">LT</td>
			<td width="23" align="center" valign="middle" class="main_3">TH</td>
			<td width="57" align="center" valign="middle" class="main_3">Tổng</td>
		
			<td width="126" align="center" valign="middle" class="main_3">&nbsp;</td>
		  </tr>
		  <tr>
			<td width="36" align="center" valign="middle" class="main_3">1</td>
		
			<td width="35" align="center" valign="middle" class="main_3">2</td>
			<td width="33" align="center" valign="middle" class="main_3">3</td>
			<td align="center" valign="middle" class="main_3">4</td>
			<td align="center" valign="middle" class="main_3">5</td>
			<td align="center" valign="middle" class="main_3">6</td>
			<td align="center" valign="middle" class="main_3">7</td>
		
			<td width="25" align="center" valign="middle" class="main_3">8</td>
			<td width="31" align="center" valign="middle" class="main_3">9</td>
			<td align="center" valign="middle" class="main_3">10</td>
			<td align="center" valign="middle" class="main_3">11</td>
			<td align="center" valign="middle" class="main_3">12</td>
			<td align="center" valign="middle" class="main_3">13</td>
		
			<td align="center" valign="middle" class="main_3">14</td>
			<td align="center" valign="middle" class="main_3">15</td>
			<td align="center" valign="middle" class="main_3">A 16 B </td>
			<td align="center" valign="middle" class="main_3">20</td>
		  </tr>
		   <?php
			$i = 0;
			  while ($rows = mysql_fetch_array($result))
			  {	
				$lophp->setMaLopHP($rows['malophp']);
				$resultdsnhomth = $lophp->dsNhomThucHanh();
				
				//$nhatki->setMaLopHP($rows['malophp']);
				if ($rows['manhom']==1 || $rows['manhom']==3 )
				{
					$i++;
					$c = 2- $i%2;
		  ?>
		  <tr>
			<td align="center" valign="middle"  class="main_3"><?php echo $i?></td>
		
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['maso']?></td>
			<td width="120" align="left" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['hoten']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['mahp']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['sotc']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['malophp']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['siso']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['sotietlithuyet']?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $lophp->soTietTHQuyChuanTheoKH();?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['sotietlithuyet']+$lophp->soTietTHQuyChuanTheoKH(); ?></td>
		
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $lophp->tongSoTietDaDay();?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $lophp->soTietTHQuyChuanTT();?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $lophp->tongSoTietDaDay() + $lophp->soTietTHQuyChuanTT();?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $rows['sotietlithuyet']-$lophp->tongSoTietDaDay();?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo $lophp->soTietTHQuyChuanTheoKH() - $lophp->soTietTHQuyChuanTT();?></td>
			<td align="center" valign="middle" class='level_1_<?php echo $c?>'><?php echo ($rows['sotietlithuyet']+$lophp->soTietTHQuyChuanTheoKH())-($lophp->tongSoTietDaDay() + $lophp->soTietTHQuyChuanTT()); ?></td>
			<td align="left" valign="middle" class='level_1_<?php echo $c?>'>
				<?php
					$j=0;
					$num = mysql_num_rows($resultdsnhomth);
					if ($num>0) echo "Chia làm ".$num." nhóm";
					while ($rowsdsnhomth = mysql_fetch_array($resultdsnhomth)){
						$j++;
						echo "-"."Nhóm ".$j.": ".$rowsdsnhomth['siso']." SV";
					}
				?>	</td>
		  </tr>
		  <?php
				}
			}
			?>
			 <tr>
				<td colspan="17" align="center" valign="middle"><input type="button" name="btndownload" value="Download" onclick="printTL('<?php echo $namhoc?>','<?php echo $hocki?>','<?php echo $mabm?>')" class="button_1"/></td>
			</tr>
		</table>
	</td>
  </tr>
 
</table>
</body>
</html>
